<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>在线用户 - OpenVPN 监控系统</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1><i class="fas fa-shield-alt"></i> OpenVPN 监控系统</h1>
            <nav class="nav">
                <a href="/" class="nav-link"><i class="fas fa-home"></i> 首页</a>
                <a href="/online" class="nav-link active"><i class="fas fa-users"></i> 在线用户</a>
                <a href="/history" class="nav-link"><i class="fas fa-history"></i> 连接历史</a>
            </nav>
        </header>

        <main class="main">
            <div class="page-header">
                <h2><i class="fas fa-users"></i> 在线用户监控</h2>
                <div class="page-actions">
                    <button class="refresh-btn" onclick="refreshOnlineUsers()">
                        <i class="fas fa-sync-alt"></i> 刷新
                    </button>
                    <div class="auto-refresh">
                        <label>
                            <input type="checkbox" id="auto-refresh" checked>
                            自动刷新 (30秒)
                        </label>
                    </div>
                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h3><i class="fas fa-list"></i> 当前在线用户列表</h3>
                    <span class="user-count" id="user-count">0 个用户在线</span>
                </div>
                <div class="card-content">
                    <div class="table-container">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th><i class="fas fa-user"></i> 用户名</th>
                                    <th><i class="fas fa-network-wired"></i> 虚拟地址</th>
                                    <th><i class="fas fa-map-marker-alt"></i> 地理位置</th>
                                    <th><i class="fas fa-calendar"></i> 连接时间</th>
                                    <th><i class="fas fa-sync"></i> 最后更新</th>
                                </tr>
                            </thead>
                            <tbody id="online-users-table">
                                <tr>
                                    <td colspan="8" class="loading">
                                        <i class="fas fa-spinner fa-spin"></i>
                                        正在加载数据...
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h3><i class="fas fa-chart-pie"></i> 流量统计</h3>
                </div>
                <div class="card-content">
                    <div class="traffic-stats">
                        <div class="traffic-item">
                            <div class="traffic-icon download">
                                <i class="fas fa-download"></i>
                            </div>
                            <div class="traffic-info">
                                <h4>总接收流量</h4>
                                <p id="total-received">0 B</p>
                            </div>
                        </div>
                        <div class="traffic-item">
                            <div class="traffic-icon upload">
                                <i class="fas fa-upload"></i>
                            </div>
                            <div class="traffic-info">
                                <h4>总发送流量</h4>
                                <p id="total-sent">0 B</p>
                            </div>
                        </div>
                        <div class="traffic-item">
                            <div class="traffic-icon total">
                                <i class="fas fa-exchange-alt"></i>
                            </div>
                            <div class="traffic-info">
                                <h4>总流量</h4>
                                <p id="total-traffic">0 B</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>

        <footer class="footer">
            <p>&copy; 2024 OpenVPN 监控系统. 服务器: {{ config.OPENVPN_HOST }}:{{ config.OPENVPN_PORT }}</p>
        </footer>
    </div>

    <script src="{{ url_for('static', filename='js/online.js') }}"></script>
</body>
</html> 